import React, { useState } from 'react'
import axios from '../../http'
function Myinput({ value: [state, setState] }) {
    return <div>
        <input type="text" value={state} onInput={(e) => setState(e.target.value)} />
    </div>
}


export default function index() {
    let [title, setTitle] = useState("")
    let [price, setprice] = useState("")
    let [count, setcount] = useState("")
    let [img, setimg] = useState("")
    let sub = async () => {
        let res = await axios.get("/egg/sub", { params: { title, price, count, img } })
        console.log(res)
        alert(res.data.info)
    }
    return (
        <div>
            <h1>管理员页面</h1>
            title <Myinput value={[title, setTitle]}></Myinput>
            price <Myinput value={[price, setprice]}></Myinput>
            count <Myinput value={[count, setcount]}></Myinput>
            img <Myinput value={[img, setimg]}></Myinput>
            <button onClick={sub}>提交</button>
        </div>
    )
}
